<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <title>
            阳光成单系统
        </title>
        <meta name="renderer" content="webkit">
        <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
        <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
        <meta name="apple-mobile-web-app-status-bar-style" content="black">
        <meta name="apple-mobile-web-app-capable" content="yes">
        <meta name="format-detection" content="telephone=no">
        <link rel="stylesheet" href="./css/x-admin.css" media="all">
        <script src="./js/jquery.min.js"></script>
    </head>
    <body>
        <div class="x-nav">
            <span class="layui-breadcrumb">
              <a><cite>首页</cite></a>
              <a><cite>会员管理</cite></a>
              <a><cite>问题/资讯列表</cite></a>
            </span>
            <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right"  href="javascript:location.replace(location.href);" title="刷新"><i class="layui-icon" style="line-height:30px">ဂ</i></a>
        </div>
        <div class="x-body">
         <div class="demoTable x-center"">   
			  商品名称：
			  <div class="layui-inline">
			    <input class="layui-input" name="par1" placeholder="请输入商品名称关键字" id="par1" autocomplete="off">
			  </div>
			  商品品牌：
			  <div class="layui-inline">
			    <input class="layui-input" name="par2" placeholder="请输入品牌关键字" id="par2" autocomplete="off">
			  </div>
			  商品类别：
			  <!-- <div class="layui-inline">
			    <input class="layui-input" name="par3" placeholder="请输入商品类别关键字" id="par3" autocomplete="off">
			  </div> -->
			   <div class="layui-inline layui-form x-center" style="margin-top: 15px; margin-bottom: 15px;">
                    <div class="layui-input-inline" style="width:120px;text-align: left">
                        <select  name="par3" id="par3" lay-verify="required" lay-filter="informationcategory" >
                          
                        </select>
                    </div>
</div>  
			  <button class="layui-btn" data-type="reload">搜索</button>
			</div>
			<div  id="dd1"   style="display:none">
            <form class="layui-form" lay-filter="addM1" id="ff1">
                <div class="layui-form-item">
                    <label for="username" class="layui-form-label">
                        <span class="x-red">*</span>商品名称
                    </label>
                    <div class="layui-input-inline">
                        <input type="text" id="name" name="name" required="" 
                        autocomplete="off" onblur="checkA()" class="layui-input">
                    </div>
                    <div class="layui-form-mid layui-word-aux">
                        <span class="x-red">*</span><span class="x-red" id="t1"></span>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label for="phone" class="layui-form-label">
                        <span class="x-red">*</span>商品品牌
                    </label>
                    <div class="layui-input-inline">
                        <input type="text" id="caizhi" name="caizhi" required="" 
                        autocomplete="off" onblur="checkB()" class="layui-input">
                    </div>
                    <div class="layui-form-mid layui-word-aux">
                        <span class="x-red">*</span><span class="x-red" id="t2"></span>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label for="L_email" class="layui-form-label">
                        <span class="x-red">*</span>商品价格
                    </label>
                    <div class="layui-input-inline">
                        <input type="text" id="price" name="price" required="" 
                        autocomplete="off" onblur="checkC()" class="layui-input">
                    </div>
                    <div class="layui-form-mid layui-word-aux">
                        <span class="x-red">*</span><span class="x-red" id="t3"></span>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label for="L_email" class="layui-form-label">
                        <span class="x-red">*</span>商品图片
                    </label>
                    <div class="layui-input-inline">
                        <input type="text" id="pic0" name="pic0" required="" 
                        autocomplete="off" onblur="checkD()" class="layui-input">
                    </div>
                    <div class="layui-form-mid layui-word-aux">
                        <span class="x-red">*</span>
                    </div>
                    <button type="button" class="layui-btn" id="test1">
					  <i class="layui-icon">&#xe67c;</i>上传图片
					</button>
                </div>
                <div class="layui-form-item">
                    <label for="L_email" class="layui-form-label">
                        <span class="x-red">*</span>商品分类
                    </label>
                    <!-- <div class="layui-input-inline">
                        <input type="text" id="f_pcid" name="f_pcid" required="" 
                        autocomplete="off" class="layui-input">
                    </div> -->
                      <div class="layui-form x-center" style="margin-top: 15px;">
                    <div class="layui-input-inline" onmouseout="checkE()" style="width:120px;text-align: left">
                        <select  name="spfl" id="spfl" lay-verify="required" lay-filter="informationcategory" >
                          
                        </select>
                    </div>
</div>  
                    <div class="layui-form-mid layui-word-aux">
                        <span class="x-red">*</span><span class="x-red" id="t4"></span>
                    </div>
                </div>
               <!--  <div class="layui-form-item">
                    <label for="L_email" class="layui-form-label">
                        <span class="x-red">*</span>是否显示在首页
                    </label> -->
                    <!-- <div class="layui-input-inline">
                        <input type="text" id="ext1" name="ext1" required="" 
                        autocomplete="off" class="layui-input">
                    </div> -->
                       <!-- <div class="layui-form x-center" style="margin-top: 15px;">
                    <div class="layui-input-inline" onmouseout="checkF()" style="width:120px;text-align: left">
                        <select  name="ext1" id="ext1" lay-verify="required" lay-filter="informationcategory" >
                          <option value="">--请选择--</option>
                          <option value="是">是</option>
                          <option value="否">否</option>
                        </select>
                    </div>
                </div>  -->
                   <!--  <div class="layui-form-mid layui-word-aux">
                        <span class="x-red">*</span><span class="x-red" id="t5"></span>
                    </div>
                </div> -->
                <div class="layui-form-item">
				    <label class="layui-form-label"> <span class="x-red">*</span>是否显示到首页</label>
				    <div class="layui-input-block">
				      <input type="radio" name="ext11" id="ext1" value="是" title="是">
				      <input type="radio" name="ext11" id="ext1" value="否" title="否" checked="checked">
				    </div>
				  </div> 
                <!-- <div class="layui-form-item">
                    <label for="role" class="layui-form-label">
                        <span class="x-red">*</span>邮箱
                    </label>
                    <div class="layui-input-inline">
                      <select name="role">
                        <option value="">请选择角色</option>
                        <option value="超级管理员">超级管理员</option>
                        <option value="编辑人员">编辑人员</option>
                        <option value="问题维护">问题维护</option>
                      </select>
                    </div>
                </div> -->
                <!-- <div class="layui-form-item">
                    <label for="L_repass" class="layui-form-label">
                        <span class="x-red">*</span>确认密码
                    </label>
                    <div class="layui-input-inline">
                        <input type="password" id="L_repass" name="repass" required="" lay-verify="repass"
                        autocomplete="off" class="layui-input">
                    </div>
                </div> -->
                <div class="layui-form-item">
                    <label for="L_repass" class="layui-form-label">
                    </label>
                    <input class="layui-btn" value="增加" id="addbtn">
                </div>
            </form>
        </div>
        <div  id="dd2"   style="display:none">
            <form class="layui-form" lay-filter="updateM1" >
             <div class="layui-form-item">
                    <label for="username" class="layui-form-label">
                        <span class="x-red">*</span>商品编号
                    </label>
                    <div class="layui-input-inline">
                        <input type="text" id="id1" name="id" required="" 
                        autocomplete="off" readonly="sreadonly" class="layui-input">
                    </div>
                    <div class="layui-form-mid layui-word-aux">
                        <span class="x-red">*</span>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label for="username" class="layui-form-label">
                        <span class="x-red">*</span>商品名称
                    </label>
                    <div class="layui-input-inline">
                        <input type="text" id="name1" name="name"  required="" 
                        autocomplete="off" onblur="checkA1()" class="layui-input">
                    </div>
                    <div class="layui-form-mid layui-word-aux">
                        <span class="x-red">*</span><span class="x-red" id="t6"></span>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label for="phone" class="layui-form-label">
                        <span class="x-red">*</span>商品品牌
                    </label>
                    <div class="layui-input-inline">
                        <input type="text" id="caizhi1" name="caizhi" required="" 
                        autocomplete="off" onblur="checkB1()" class="layui-input">
                    </div>
                    <div class="layui-form-mid layui-word-aux">
                        <span class="x-red">*</span><span class="x-red" id="t7"></span>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label for="L_email" class="layui-form-label">
                        <span class="x-red">*</span>商品价格
                    </label>
                    <div class="layui-input-inline">
                        <input type="text" id="price1" name="price" required="" 
                        autocomplete="off" onblur="checkC1()" class="layui-input">
                    </div>
                    <div class="layui-form-mid layui-word-aux">
                        <span class="x-red">*</span><span class="x-red" id="t8"></span>
                    </div>
                </div>
                 <div class="layui-form-item">
                    <label for="L_email" class="layui-form-label">
                        <span class="x-red">*</span>商品图片
                    </label>
                    <div class="layui-input-inline">
                        <input type="text" id="pic01" name="pic0" required="" 
                        autocomplete="off" onblur="checkD1()" class="layui-input">
                    </div>
                    <div class="layui-form-mid layui-word-aux">
                        <span class="x-red">*</span>
                    </div>
                    <button type="button" class="layui-btn" id="test2">
					  <i class="layui-icon">&#xe67c;</i>上传图片
					</button>
                </div>
                 <div class="layui-form-item">
                    <label for="L_email" class="layui-form-label">
                        <span class="x-red">*</span>商品分类
                    </label>
                    <!--  <div class="layui-input-inline">
                        <input type="text" id="f_pcid1" name="f_pcid" required="" 
                        autocomplete="off" class="layui-input">
                    </div> --> 
                     <div class="layui-form x-center" style="margin-top: 15px;">
                    <div class="layui-input-inline" onmouseout="checkE1()" style="width:120px;text-align: left">
                        <select  name="f_pcid" id="f_pcid1" lay-verify="required" lay-filter="informationcategory" >
                          
                        </select>
                    </div>
</div>  
                    <div class="layui-form-mid layui-word-aux">
                        <span class="x-red">*</span><span class="x-red" id="t9"></span>
                    </div>
                </div>
                <!--  <div class="layui-form-item">
                    <label for="L_pass" class="layui-form-label">
                        <span class="x-red">*</span>是否显示在首页
                    </label> -->
                    <!--  <div class="layui-input-inline">
                        <input type="text" id="ext11" name="ext1" required="" 
                        autocomplete="off" class="layui-input">
                    </div>  -->
                    <!--  <div class="layui-form x-center" style="margin-top: 15px;">
                    <div class="layui-input-inline" onmouseout="checkF1()" style="width:120px;text-align: left">
                        <select  name="ext1" id="ext11" lay-verify="required" lay-filter="informationcategory" >
                          <option value="">--请选择--</option>
                          <option value="是">是</option>
                          <option value="否">否</option>
                        </select>
                    </div>
                </div> 
                    <div class="layui-form-mid layui-word-aux">
                         <span class="x-red">*</span><span class="x-red" id="t10"></span>
                    </div>
                </div> -->
                <div class="layui-form-item">
				    <label class="layui-form-label"> <span class="x-red">*</span>是否显示到首页</label>
				    <div class="layui-input-block">
				      <input type="radio" name="ext1" id="ext1" value="是" title="是">
				      <input type="radio" name="ext1" id="ext1" value="否" title="否" checked="checked">
				    </div>
				  </div> 
                <!-- <div class="layui-form-item">
                    <label for="L_repass" class="layui-form-label">
                        <span class="x-red">*</span>确认密码
                    </label>
                    <div class="layui-input-inline">
                        <input type="password" id="L_repass" name="repass" required="" lay-verify="repass"
                        autocomplete="off" class="layui-input">
                    </div> 
                </div> -->
                <div class="layui-form-item">
                    <label for="L_repass" class="layui-form-label">
                    </label>
                    <input class="layui-btn" value="修改" id="updatebtn">
                </div>
            </form>
        </div>
            <!-- <form class="layui-form x-center" action="" style="width:800px">
                <div class="layui-form-pane" style="margin-top: 15px;">
                  <div class="layui-form-item">
                    <label class="layui-form-label">日期范围</label>
                    <div class="layui-input-inline">
                      <input class="layui-input" placeholder="开始日" id="LAY_demorange_s">
                    </div>
                    <div class="layui-input-inline">
                      <input class="layui-input" placeholder="截止日" id="LAY_demorange_e">
                    </div>
                    <div class="layui-input-inline">
                      <input type="text" name="username" id="username"  placeholder="标题" autocomplete="off" class="layui-input">
                    </div>
                    <div class="layui-input-inline" style="width:80px">
                        <button class="layui-btn"  lay-submit="" lay-filter="sreach"><i class="layui-icon">&#xe615;</i></button>
                    </div>
                  </div>
                </div> 
            </form> -->
            <xblock><button class="layui-btn layui-btn-danger" onclick="delAll()"><i class="layui-icon">&#xe640;</i>批量删除</button><button class="layui-btn" onclick="question_add('添加问题','question-add.html','600','500')"><i class="layui-icon">&#xe608;</i>添加</button><span class="x-right" style="line-height:40px"></span></xblock>
            <table class="layui-table" lay-filter='test' id="demo">
              
            </table>

            <div id="page"></div>
        </div>

        <script type="text/html" id="titleTpl">
				<img src="../{{d.pic0}}" onmousemove="hoverOpenImg(this)"  class="layui-table-link" />
		</script>
        <script src="./lib/layui/layui.js" charset="utf-8"></script>
        <script src="./js/x-layui.js" charset="utf-8"></script>
        <script>
            layui.use('table', function(){
			  var table = layui.table;
			  //第一个实例
			  table.render({
			    elem: '#demo'
			    ,height: 512
			    ,url: '../ProductServlet?oid=4' //数据接口
			    ,page: true //开启分页
			    ,cols: [[ //表头
			    	{type:'checkbox', fixed: 'left'}
			      ,{field: 'id', title: '编号', width:80, sort: true, fixed: 'left'}
			      ,{field: 'name', title: '商品名称', width:180}
			      ,{field: 'caizhi', title: '品牌', width:100}
			      ,{field: 'price', title: '价格', width:110}
			      ,{field: 'pic0', title: '商品图片', width:180 ,templet: '#titleTpl'}
			/*       ,{field: 'f_pcid', title: '商品分类编号', width:115}
			 */      ,{field: 'cname', title: '商品类别', width:110}
			      /* ,{field: 'weight', title: '宽度', width:80}
			      ,{field: 'isT', title: '是否', width:80} */
			      ,{field: 'ext1', title: '是否显示在首页', width:150}
			      ,{fixed: 'right', width:250, align:'center', toolbar: '#barDemo'}
			
			    ]]
			    ,id:"showAll" 
			  });
			  //搜索框
			  var $ = layui.$, active = {
			    reload: function(){
			      var par1 = $('#par1');  //jquery的写法   根据id获取名称的对象
			      var par2 = $('#par2');  //jquery的写法   根据id获取品牌的对象
			      var par3 = $('#par3');  //jquery的写法   根据id获取品牌的对象
			      //执行重载
			      table.reload('showAll', {  //showAll是上边查询代码的id
			        page: {
			          curr: 1 //重新从第 1 页开始
			        }
			   , method: 'POST'
			        ,where: {
			         /*  key: {
			            id: demoReload1.val()
			          } */
			          name: par1.val()   //获取名称文本框的值
			          ,caizhi:par2.val()  //获取品牌文本框的值
			          ,f_pcid:par3.val()  //获取分类的值
			        }
			      });
			    }
			  };
			  
			  $('.demoTable .layui-btn').on('click', function(){
			    var type = $(this).data('type');
			    active[type] ? active[type].call(this) : '';
			  });
			});
/*   <a class="layui-btn layui-btn-xs" lay-event="detail">查看</a> */
</script>
<script type="text/html" id="barDemo">
  <a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a>
  <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
  
</script>
<script type="text/javascript">
layui.use(["table","jquery"],function(){
  var table=layui.table;
  var $=layui.jquery;
   table.on('tool(test)', function(obj){ //注：tool是工具条事件名，test是table原始容器的属性 lay-filter="对应的值"
  var data = obj.data; //获得当前行数据
  var layEvent = obj.event; //获得 lay-event 对应的值（也可以是表头的 event 参数对应的值）
  var tr = obj.tr; //获得当前行 tr 的DOM对象
 
  if(layEvent === 'detail'){ //查看
    
  } else if(layEvent === 'del'){ //删除
      layer.open({
            type : 1,
            content : '<div style="padding: 20px 80px;">确定删除记录?</div>',
            btn : [ '确定', '取消' ],
            yes : function(index, layero) {
                $.ajax({
                    url : "../ProductServlet?oid=5",//数据接口
                    data : {
                        "id" : data.id
                    },
                    dataType : "text",
                    success : function(r) {
                        if(r>0){
                            layer.msg("删除成功！");
                           obj.del();
                           layer.close(index);
                           table.reload("demo");
                        }else{
                            layer.msg("删除失败！");
                        }
                    },
                    error : function() {
                    }
                });
            }
        });

  } else if(layEvent === 'edit'){ //编辑
 	var form=layui.form;//alert(data);
  	        form.val("updateM1",data);
				layer.open({
	            type : 1,
	            title:'修改页面',
	            content : $("#dd2"),
	            area: ['500px', '500px']
	        	});
  }
});
});
  
</script>
<script>
//验证
function checkA(){
    var name = document.getElementById("name").value;
    if(name!=""){
            document.getElementById("name").style="";
    	    document.getElementById("t1").innerHTML = "";
    		return true;
    }else{
            document.getElementById("t1").innerHTML = "必填,不能为空";
    		document.getElementById("name").style="border:1px solid red";
    		return false;
    }
}
function checkB(){
    var caizhi = document.getElementById("caizhi").value;
    if(caizhi!=""){
            document.getElementById("caizhi").style="";
    	    document.getElementById("t2").innerHTML = "";
    		return true;
    }else{
            document.getElementById("t2").innerHTML = "必填,不能为空";
    		document.getElementById("caizhi").style="border:1px solid red";
    		return false;
    }
}
function checkC(){
    var price = document.getElementById("price").value;
    if(price!=""){
            document.getElementById("price").style="";
    	    document.getElementById("t3").innerHTML = "";
    		return true;
    }else{
            document.getElementById("t3").innerHTML = "必填,不能为空";
    		document.getElementById("price").style="border:1px solid red";
    		return false;
    }
}
function checkD(){
    var pic0 = document.getElementById("pic0").value;
    if(pic0!=""){
            document.getElementById("pic0").style="";
    	    /* document.getElementById("t3").innerHTML = ""; */
    		return true;
    }else{
            /* document.getElementById("t3").innerHTML = "必填,不能为空"; */
    		document.getElementById("pic0").style="border:1px solid red";
    		return false;
    }
}
function checkE(){
    var f_pcid = document.getElementById("spfl").value;
    if(f_pcid!=0){
            document.getElementById("spfl").style="";
    	    document.getElementById("t4").innerHTML = "";
    		return true;
    }else{
            document.getElementById("t4").innerHTML = "必填,不能为空";
    		document.getElementById("spfl").style="border:1px solid red";
    		return false;
    }
}
function checkA1(){
    var name1 = document.getElementById("name1").value;
    if(name1!=""){
            document.getElementById("name1").style="";
    	    document.getElementById("t6").innerHTML = "";
    		return true;
    }else{
            document.getElementById("t6").innerHTML = "必填,不能为空";
    		document.getElementById("name1").style="border:1px solid red";
    		return false;
    }
}
function checkB1(){
    var caizhi1 = document.getElementById("caizhi1").value;
    if(caizhi1!=""){
            document.getElementById("caizhi1").style="";
    	    document.getElementById("t7").innerHTML = "";
    		return true;
    }else{
            document.getElementById("t7").innerHTML = "必填,不能为空";
    		document.getElementById("caizhi1").style="border:1px solid red";
    		return false;
    }
}
function checkC1(){
    var price1 = document.getElementById("price1").value;
    if(price1!=""){
            document.getElementById("price1").style="";
    	    document.getElementById("t8").innerHTML = "";
    		return true;
    }else{
            document.getElementById("t8").innerHTML = "必填,不能为空";
    		document.getElementById("price1").style="border:1px solid red";
    		return false;
    }
}
function checkD1(){
    var pic01 = document.getElementById("pic01").value;
    if(pic01!=""){
            document.getElementById("pic01").style="";
    	    /* document.getElementById("t3").innerHTML = ""; */
    		return true;
    }else{
            /* document.getElementById("t3").innerHTML = "必填,不能为空"; */
    		document.getElementById("pic01").style="border:1px solid red";
    		return false;
    }
}
function checkE1(){
    var f_pcid = document.getElementById("f_pcid1").value;
    if(f_pcid!=0){
            document.getElementById("f_pcid1").style="";
    	    document.getElementById("t9").innerHTML = "";
    		return true;
    }else{
            document.getElementById("t9").innerHTML = "必填,不能为空";
    		document.getElementById("f_pcid1").style="border:1px solid red";
    		return false;
    }
}
//添加
function question_add(){
  layer.open({
                  type:1,
                  content:$("#dd1"),
                  area:['500px','500px']
                });

}
//用ajax发送请求
$(function(){
    $("#addbtn").click(function(){
    //用js获取文本框得值
    var name = document.getElementById("name").value;
    var caizhi = document.getElementById("caizhi").value;
    var price = document.getElementById("price").value;
    var pic0 = document.getElementById("pic0").value;
    //var ext1 = $("#ext1").val();
    var f_pcid = document.getElementById("spfl").value;
   // var ext1 = document.getElementById("ext1").value; 
    var ext1 = $("input[name='ext11']:checked").val();
    //alert(title+","+content+","+f_ncid+","+ext1);
    if(!(checkA()&checkB()&checkC()&checkD()&checkE())){
         return;
    }
		$.post("../ProductServlet?oid=7",{
		name:name,
		caizhi:caizhi,
		price:price,
		pic0:pic0,
		f_pcid:f_pcid,
		ext1:ext1
		},function(r){
		if(r>0){
		 layer.msg("添加成功！");
		  window.setTimeout(function(){ 
		 window.location.href="javascript:location.replace(location.href)";
		 },600); 
		}else{
		 layer.msg("添加失败！");
		  window.setTimeout(function(){ 
         window.location.href="javascript:location.replace(location.href)";
          },600); 
	    }
		});
		
		
		});	
//修改
$("#updatebtn").click(function(){
    var id = document.getElementById("id1").value;
    var name = document.getElementById("name1").value;
    var caizhi = document.getElementById("caizhi1").value;
    var price = document.getElementById("price1").value;
    var pic0 = document.getElementById("pic01").value;
    //var ext1 = $("#ext1").val();
    var f_pcid = document.getElementById("f_pcid1").value;
    //var ext1 = document.getElementById("ext11").value; 
     var ext1 = $("input[name='ext1']:checked").val();
 //alert(id+","+name+","+caizhi+","+price+","+pic0+","+f_pcid+","+ext1);
  if(!(checkA1()&checkB1()&checkC1()&checkD1()&checkE1())){
         return;
    }
    $.post("../ProductServlet?oid=8",{
        id:id,
        name:name,
		caizhi:caizhi,
		price:price,
		pic0:pic0,
		f_pcid:f_pcid,
		ext1:ext1
    },function(r){
    if(r>0){
		 layer.msg("修改成功！");
		  window.setTimeout(function(){ 
		 window.location.href="javascript:location.replace(location.href)";
		 },600); 
		}else{
		 layer.msg("修改失败！");
		  window.setTimeout(function(){ 
         window.location.href="javascript:location.replace(location.href)";
          },600); 
	    }
    });
    });
    });


//批量删除
function delAll(){
var arr = layui.table.checkStatus('showAll').data; //获取当前行的数据object类型
//alert(arr[0].id);   取值案例
var temp = ""; 
for(var i=0;i<arr.length;i++){//用javascript的for/in循环遍历对象的属性
    temp +=arr[i].id+",";
}
//alert(temp);//已经得到选中行的所有id
   layer.open({
            type : 1,
            content : '<div style="padding: 20px 80px;">确定删除记录?</div>',
            btn : [ '确定', '取消' ],
            yes : function(index, layero) {
                $.ajax({
                    url : "../ProductServlet?oid=6",//数据接口
                    data : {
                        "temp" : temp
                    },
                    dataType : "text",
                    success : function(r) {
                        if(r>0){
                            layer.msg("删除成功！");
                             window.setTimeout(function(){
                         window.location.href="javascript:location.replace(location.href)";
                          },600); 
                        }else{
                            layer.msg("删除失败！");
                             window.setTimeout(function(){
                         window.location.href="javascript:location.replace(location.href)";
                          },600);
                        }
                    },
                    error : function() {
                    }
                });
            }
        }); 
        }

</script>
<script>
//添加的下拉框
 layui.use(['form'],function () {
	 var form = layui.form;
	 var spfl=document.getElementById("spfl");
	//检查项目添加到下拉框中
		 $.ajax({
			    type: "POST",
			    url: '../ProductServlet?oid=9',
			    dataType:"json",
			    success: function (data) {
			    	for(var i=0;i<data.length;i++){
			    		var op=document.createElement("option");
			    		op.text=data[i].name;
			    		op.value=data[i].id;
			    		spfl.add(op);
			    	}
			    	var op1=document.createElement("option");
			    	op1.text="--请选择--";
			    	op1.value="";
			    	spfl.add(op1,spfl.options[0]);
			    	spfl.selectedIndex=0;
					form.render("select");
			    }
			});
	   });
	   
	   //修改的
	   layui.use(['form'],function () {
	 var form = layui.form;
	 var f_pcid=document.getElementById("f_pcid1");
	 
	 
	//检查项目添加到下拉框中
		 $.ajax({
			    type: "POST",
			    url: '../ProductServlet?oid=9',
			    dataType:"json",
			    success: function (data) {
			    	for(var i=0;i<data.length;i++){
			    		var op=document.createElement("option");
			    		op.text=data[i].name;
			    		op.value=data[i].id;
			    		f_pcid.add(op);
			    	}
			    	var op1=document.createElement("option");
			    	op1.text="--请选择--";
			    	op1.value="";
			    	f_pcid.add(op1,f_pcid.options[0]);
			    	f_pcid.selectedIndex=0;
					form.render("select");
			    }
			});
	   });
	   
	   //搜索的
layui.use(['form'],function () {
	 var form = layui.form;
	
	 var f_pcid=document.getElementById("par3");
	 
	//检查项目添加到下拉框中
		 $.ajax({
			    type: "POST",
			    url: '../ProductServlet?oid=9',
			    dataType:"json",
			    success: function (data) {
			    	for(var i=0;i<data.length;i++){
			    		var op=document.createElement("option");
			    		op.text=data[i].name;
			    		op.value=data[i].id;
			    		f_pcid.add(op);
			    	}
			    	var op1=document.createElement("option");
			    	op1.text="--请选择--";
			    	op1.value="";
			    	f_pcid.add(op1,f_pcid.options[0]);
			    	f_pcid.selectedIndex=0;
					form.render("select");
			    }
			});
	   });

 
</script>
 <script>
 //图片上传
layui.use('upload', function(){
  var upload = layui.upload;
   
  //执行实例
  var uploadInst = upload.render({
    elem: '#test1' //绑定元素
    ,url: '../ProductServlet?oid=10' //上传接口
    ,done: function(res){
      //上传完毕回调
      
      layer.msg(res.msg);
      //上传文件成功后将路径填写到文本框内
      document.getElementById("pic0").value=res.data;
      
    }
    ,error: function(){
      //请求异常回调
    }
  });
  //修改的上传图片
  //执行实例
  var uploadInst = upload.render({
    elem: '#test2' //绑定元素
    ,url: '../ProductServlet?oid=10' //上传接口
    ,done: function(res){
      //上传完毕回调
      
      layer.msg(res.msg);
      //上传文件成功后将路径填写到文本框内
      document.getElementById("pic01").value=res.data;
      
    }
    ,error: function(){
      //请求异常回调
    }
  });
});
</script>
<script>
function hoverOpenImg(){
        var img_show = null; // tips提示
        $('td img').hover(function(){
            //alert($(this).attr('src'));
            var img = "<img class='img_msg' src='"+$(this).attr('src')+"' style='width:200px;' />";
            img_show = layer.tips(img, this,{
                tips:[2, 'rgba(50,50,50,.10)']
                ,area: ['220px']
            });
        },function(){
            layer.close(img_show);
        });
        $('td img').attr('style','max-width:70px');
    }
    </script>
    </body>
</html>